# Maintainer: David Runge <dvzrv@archlinux.org>

_name=subprocess-tee
pkgname=python-subprocess-tee
pkgver=0.4.1
pkgrel=3
pkgdesc="A subprocess.run that works like tee"
arch=(any)
url="https://github.com/pycontribs/subprocess-tee"
license=(MIT)
depends=(python)
makedepends=(git python-build python-installer python-setuptools python-setuptools-scm python-wheel)
checkdepends=(ansible-core molecule python-enrich python-pytest python-pytest-xdist)
optdepends=('python-enrich: for rich text rendering')
source=(https://files.pythonhosted.org/packages/source/${_name::1}/$_name/$_name-$pkgver.tar.gz)
sha512sums=('683813096c4bb78a4263075ba8590a926134ec92db5e2e72ed98ab1db9e231768adc15bb4273ba138f9a1b2a14ae4050d0b6acc76d483d0f3530f376ce8d9eee')
b2sums=('779a8b5381155e8d524b6715ab9cc37f8e55565dd378a2d256648d56f018dc71860b0db2a50572a5e03fab7d2de5cd691be53c49c1aa79e756b4eb8a8d5878a5')

build() {
  cd $_name-$pkgver
  python -m build --wheel --no-isolation
}

check() {
  cd $_name-$pkgver
  export PYTHONPATH="build:$PYTHONPATH"
  pytest -vv -c /dev/null
}

package() {
  local _site_packages=$(python -c "import site; print(site.getsitepackages()[0])")

  cd $_name-$pkgver
  python -m installer --destdir="$pkgdir" dist/*.whl
  install -vDm 644 README.md -t "$pkgdir/usr/share/doc/$pkgname/"
  install -vDm 644 LICENSE -t "$pkgdir/usr/share/licenses/$pkgname/"
  # remove tests: https://github.com/pycontribs/subprocess-tee/issues/61
  rm -frv "$pkgdir/$_site_packages/subprocess_tee/test/"
}
